package com.tonyodev.fetch2core;

/**
 * 文件类
 *
 * @since 2021-05-20
 */
public class FileSlice {
    private final int id;
    private final int position;
    private final long startBytes;
    private final long endBytes;
    private long downloaded;

    /**
     * 构造函数
     *
     * @param id id
     * @param position 位置
     * @param startBytes 开始字节
     * @param endBytes 结束字节
     * @param downloaded 下载长度
     */
    public FileSlice(int id,
                     int position,
                     long startBytes,
                     long endBytes,
                     long downloaded) {
        this.id = id;
        this.position = position;
        this.startBytes = startBytes;
        this.endBytes = endBytes;
        this.downloaded = downloaded;
    }

    public int getId() {
        return this.id;
    }

    public int getPosition() {
        return this.position;
    }

    public long getStartBytes() {
        return this.startBytes;
    }

    public long getEndBytes() {
        return this.endBytes;
    }

    public long getDownloaded() {
        return this.downloaded;
    }

    public void setDownloaded(long var1) {
        this.downloaded = var1;
    }

    public boolean isDownloaded() {
        return this.startBytes + this.downloaded == this.endBytes;
    }
}
